package math2;

import fem2.BasisManager;
import fem2.MeshPart;
import fem2.Node;

/**
 * geometry using isoparametric interpolation
 * 
 * @author hbui
 * 
 */
public abstract class IsoparametricGeometry extends Geometry {

	@Override
	public double[] valueAt(MeshPart mp, double... xi) {
		int dim = mp.getDimension();
		double[] p = new double[dim];
		Node[] nodes = mp.getNodes();
		FunctionBasisOnRnToR basis = BasisManager.getInstance().getBasis(mp.getType());
		for (int i = 0; i < nodes.length; i++) {
			double[] c = nodes[i].getPosition();
			double Ni = basis.getBasisFunction(i).valueAt(xi);
			for (int j = 0; j < dim; j++) {
				p[j] += c[j] * Ni;
			}
		}
		return p;
	}

}
